import Vue from 'vue'
import App from './App.vue'
import Vant from 'vant'
import 'vant/lib/index.css'
import axios from "axios"
import moment from 'moment'
import qs from 'qs'
import Icon from 'vue2-svg-icon/Icon.vue'
import store from './store/store.js'
import Vuex from 'vuex'
import router from './router/index.js'
// import 'lib-flexible'
import 'amfe-flexible'

// import 
// 在入口文件中（main.js），导入组件库
import vueHashCalendar from 'vue-hash-calendar'
// 引入组件CSS样式
import 'vue-hash-calendar/lib/vue-hash-calendar.css'

import '../src/assets/css/resetVui.scss'

// import '../src/assets/js/validator.js'

import dateTime from 'vue-date-time-m'
import { isRegExp } from 'util'

// import Vue from 'vue';



Vue.component('data-time', dateTime);


Vue.use(Vant);
Vue.use(Vuex);
Vue.use(moment);


//设置axios为form-data
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
axios.defaults.headers.get['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
axios.defaults.headers.delete['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
axios.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';


// 注册组件库
Vue.use(vueHashCalendar);
Vue.prototype.$axios = axios;
Vue.prototype.$qs = qs;

// POST传参序列化 
// axios.interceptors.request.use((config) => {
//   if(config.method === 'POST') {
//       config.data = qs.stringify(config.data);
//   }
//   return config;
// }, (error) => {
//   return Promise.reject(error);
// }); 
// 返回状态判断 
// axios.interceptors.response.use((res) =>{ 
//   if(res.data.Message != 'SUCCESS'){ 
//       return Promise.reject(res);
//   } 
//   return res;
// }, (error) => {
//       //404等问题可以在这里处理 
//       return Promise.reject(error); 
// })

// 配置环境变量
if(process.env.VUE_APP_ENV  === 'production'){
    console.log('生产环境');
    // axios.defaults.baseURL = process.env.VUE_APP_BASE_API;
    // console.log(axios.defaults.baseURL);
    axios.defaults.baseURL =  window.apiObj.apiUrl;
    console.log(axios.defaults.baseURL);
}
if(process.env.VUE_APP_ENV  === 'development'){
    console.log('开发环境');
    // axios.defaults.baseURL = process.env.VUE_APP_BASE_API;
}
Vue.component('icon', Icon);

//设置生产环境未flase
Vue.config.productionTip = false;

//挂载到vue的根实列上

new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
